<?php

class PrintersController extends Zend_Controller_Action {
    
    public function init(){
        $this->view->secondNavigation = new Application_View_Helper_SecondNavigation();
    }
    
    public function indexAction(){
        
    }
    
    public function addprinterAction(){
        $addPrinterForm = new Application_Form_Addprinter;
	if($this->getRequest()->isPost()){
	    if($addPrinterForm->isValid($this->getRequest()->getPost())){
		
	    }
	}
	$this->view->form = $addPrinterForm;
    }
    
    public function addcartridgeAction(){
	$addCartridgeForm = new Application_Form_Addcartridges();	
	if($this->getRequest()->isPost()){
	    if($addCartridgeForm->isValid($this->getRequest()->getPost())){
		$printersMapper = new Application_Model_Printers;
		$cartridge = new Application_Model_Cartridge;
		$cartridge->setName($addCartridgeForm->getValue('name'))
			->setStock($addCartridgeForm->getValue('stock'))
			->setColor($printersMapper->getColorById(
				$addCartridgeForm->getValue('color')));
		$printersMapper->saveCartridge($cartridge);
		$this->_redirect('/printers');		
	    }
	}
	$this->view->form = $addCartridgeForm;
    }
    
    public function cartridgesAction(){
	$printersMapper = new Application_Model_Printers;
	$this->view->cartridgesList = $printersMapper->listCartridges();
    }

    public function removeAction(){
        
    }
    
    
}

?>
